<template>
    <div id="progressdialog">
        <commonformdialog :dialogWidth="'30%'" @confirmbtn='confirmbtn' :isshowDialogs='isshowDialogs' :dialogTitle='"修改学车进度"' :topHeight='"30vh"' @closetextDialog='closetextDialog'>
            <el-form ref="proForm" :model="formData" :rules="rules" size="medium" label-width="100px">
            <el-form-item label="当前进度" prop="learnRate">
                <el-select v-model="formData.learnRate" placeholder="请选择当前进度" clearable :style="{width: '100%'}">
                <el-option v-for="(item, index) in subjectsOption" :key="index" :label="item.label" :value="item.value"
                    :disabled="item.disabled"></el-option>
                </el-select>
            </el-form-item>
            </el-form>
        </commonformdialog>
    </div>
</template>

<script>
//弹窗
import commonformdialog from '@/components/commondialog/commondialog'
import {updatelearnrate} from '@/api/student'
export default {
    data(){
        return {
            formData: {
               learnRate: undefined,
      },
      rules: {
        learnRate: [{
          required: true,
          message: '请选择修改进度',
          trigger: 'change'
        }],
      },
      subjectsOption: [{
        "label": "科目一",
        "value": 1
      }, {
        "label": "科目二",
        "value": 2
      },
      {
        "label": "科目三",
        "value": 3
      },
      {
        "label": "科目四",
        "value": 4
      }],
        }
    },
    components:{
        commonformdialog
    },
    props:{
        //是否显示弹窗
        isshowDialogs:{
            type:Boolean,
            default:false
        },
        //选择的行id
        rowid:Number
    },
    methods:{
        //关闭弹窗
        closetextDialog(){
            this.$emit('closetextDialog')
            this.$refs['proForm'].resetFields()
        },
        //确认弹窗
        confirmbtn(){
             this.$refs['proForm'].validate(async valid => {
                if (!valid) return
                // TODO 提交表单
                let params = {
                    id:this.rowid,
                    learnRate:this.formData.learnRate
                }
                let data  = await updatelearnrate(params)
                if(data.code=='0000'){
                    this.$message.success('修改学车进度成功！')
                    this.$refs['proForm'].resetFields()
                    this.$emit('refreshData')
                    this.$emit('confirmbtn')
                }
            })

        }
    },
    mounted(){

    }
}
</script>

<style scoped lang='scss'>

</style>
